Skip to content

[GEN][ZH] Fix ThingTemplate override copy to prevent mismatch with mod map and quickstart #1194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Caball009
Copy link

@Caball009 Caball009 commented Jun 25, 2025

Check out the information in the issue: #856 (comment)

Note: While this should fix all mismatching issues related to the default shellmap, custom map mismatches are not fixed. Custom maps with a map.ini file may still overwrite default data like UpgradeTemplate, which would almost certainly cause a mismatch on another map.

@Caball009 Caball009 added Bug Something is not working right, typically is user facing Major Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Stability Concerns stability of the runtime labels Jun 25, 2025
@Caball009 Caball009 changed the title [GEN][ZH] Clear old data when creating a ThingTemplate override [GEN][ZH] Fix ThingTemplate override copy to prevent mismatch for mod maps Jun 25, 2025
@Caball009 Caball009 changed the title [GEN][ZH] Fix ThingTemplate override copy to prevent mismatch for mod maps [GEN][ZH] Fix ThingTemplate override copy to prevent mismatch with mod map Jun 25, 2025
@Caball009 Caball009 changed the title [GEN][ZH] Fix ThingTemplate override copy to prevent mismatch with mod map [GEN][ZH] Fix ThingTemplate override copy to prevent mismatch with mod map and quickstart Jun 28, 2025
@Caball009 Caball009 marked this pull request as ready for review June 28, 2025 14:25
@Caball009 Caball009 requested a review from a team July 3, 2025 22:17
//-------------------------------------------------------------------------------------------------
void ThingTemplate::clearOnNewOverride()
{
// TheSuperHackers @info Clear containers that may contain pointers to data in the 'parent' template for memoization purposes.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superfluous comment, because that is already explained with comments at the function declaration and the caller.

@@ -194,6 +194,9 @@ ThingTemplate* ThingFactory::newOverride( ThingTemplate *thingTemplate )
newTemplate->markAsOverride();
child->setNextOverride(newTemplate);

// TheSuperHackers @bugfix Caball009 25/06/2025 Clear data that was valid for the 'parent' template but not for the override.
newTemplate->clearOnNewOverride();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what happens here is that the 2 SparseMatchFinder instances are copied first with *newTemplate = *child, and then they are cleared here to purge the pointers to the unrelated vector of the other ThingTemplate.

There are 2 Problems:

Problem 1

It does not cover all copies automatically. There are 3 places that copy:

  1. In ThingFactory::newTemplate
  2. In ThingFactory::newOverride (this is covered by this change)
  3. In ThingTemplate::copyFrom

Problem 2

The 2 SparseMatchFinder instances are allocated and copied before they are cleared. Their allocated memory is probably kept on clear too. This is unnecessary work and can be avoided.

We do not want to implement ThingTemplate::operator= by hand, because there are 80 or so class members. But there is something else we can do: #1234

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working right, typically is user facing Gen Relates to Generals Major Severity: Minor < Major < Critical < Blocker Stability Concerns stability of the runtime ZH Relates to Zero Hour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mismatches when using -quickstart
2 participants